from twisted.spread import pb
from twisted.internet import reactor

class loginServer(pb.Root):

	def __init__(self):
		self.data = []

	def remote_login(self, user):

		id = user['uid']
		if( id in self.data ):
			return true
		self.data.append(id)
		self.debug()
		return 1;

	def remote_logout(self, user):
		id = user['uid']
		if( id not in self.data ):
			return 0;
		self.data.remove(id)
		self.debug()

	def remote_isLogin(self, user):
		id = user['uid']
		if( id in self.data ):
			return 1
		return 0

	def debug(self):
		print self.data
    	

if __name__ == '__main__':
    reactor.listenTCP(8003, pb.PBServerFactory(loginServer()))
    print "Server Go..."
    reactor.run()